package org.bookie.model;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;

import org.bookie.model.operator.Add;
import org.bookie.model.operator.Operator;

/**
 * Class modelling a bet slip of type <code>single</code>.
 * The total stake of a 'single' BetSlip is calculated by multiplying the stake
 * by the number of {@link Wager}s. The profit calculation is delegated to an instance 
 * of {@link Operator}.
 * 
 * @author Igor Drobiazko
 */
@Entity
@DiscriminatorValue("S")
public class SingleBetSlip extends BetSlip {

	private static final long serialVersionUID = 1L;
	
	/**Used Operator*/
	@Transient
	private static Operator operator = new Add();
	
	/**Constructs an empty instance of SingleBetSlip*/
	public SingleBetSlip(){super();}
	
	/**
	 * Constructs a new instance of the SingleBetSlip. 
	 * @param user owner of the BetSlip to set
	 * @param stake stake to place
	 */
	public SingleBetSlip(User user, Double stake){
		super(user, stake);
	}
	
	/**
	 * Constructs a new instance of the SingleBetSlip from another BetSlip. 
	 * @param betSlip BetSlip to create new one from
	 */
	public SingleBetSlip(BetSlip betSlip) {
		super(betSlip);
	}
	
	/**
	 * Get the {@link Operator}.
	 */
	protected Operator getOperator() {
		return operator;
	}
	
	/**
	 * Get the total stake.
	 */
	public Double getTotalStake() {
		return new Double(getBets().size()*getStake().doubleValue());
	}
	
}
